To add a grid to your form follow next steps:
The following example will edit Desc, Quant and Price fields of the table Orders_r filtering the records using IdOrder, this field is present in both tables master and rows table.
OpenCursor( "SELECT * FROM [Orders]"); OpenCursor( "SELECT * FROM
[Orders_r]", "IdOrder = 1"); AddListCol( IDC_LIST_ROW, "Desc",
100); AddListCol( IDC_LIST_ROW, "Quant",
50); AddListCol( IDC_LIST_ROW, "Price",
50);
AddListCtrl( IDC_LIST_ROW,
"IdOrd", 2, "IdOrder");
The following example adds rows to the grid whose Id is IDC_LIST_ROW.
void CFormOrders::OnButAddRow() |
{ |
CDBGrid * pDBGrid = (CDBGrid *) GetDlgItem(IDC_LIST_ROW); |
ASSERT_VALID( pDBGrid ); |
pDBGrid->AddRecord(); |
} |